﻿<phone:PhoneApplicationPage 
    x:Class="VisualStudioAchievements.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:VisualStudioAchievements"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">
    
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <toolkit:PerformanceProgressBar VerticalAlignment="Top" x:Name="perfBar" IsIndeterminate="True" Visibility="{Binding Path=Instance.HidePerfBar,Source={StaticResource LocalBindingPoint},Converter={StaticResource PerfBarConverter}, ConverterParameter=p}"></toolkit:PerformanceProgressBar>

        <Grid Margin="0,20,0,20" Width="440" Background="{StaticResource PhoneAccentBrush}">
            <Image HorizontalAlignment="Left" Source="Images/pagelogo.png"></Image>
        </Grid>
        

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="20,0,20,20">
            <TextBlock Visibility="{Binding Path=Instance.Niners.Count,Source={StaticResource LocalBindingPoint},Converter={StaticResource CountToVisibility}}" TextAlignment="Left" FontFamily="{StaticResource PhoneFontFamilySemiLight}" FontSize="{StaticResource PhoneFontSizeLarge}" TextWrapping="Wrap" Text="add users to track their visual studio achievements." Foreground="Gray"></TextBlock>
            <ListBox Foreground="Black" ItemsSource="{Binding Path=Instance.Niners,Source={StaticResource LocalBindingPoint}}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="440" HorizontalAlignment="Center" Margin="0,0,0,20" Tap="StackPanel_Tap" Tag="{Binding Alias}" Height="180">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="80"></RowDefinition>
                                <RowDefinition Height="100"></RowDefinition>
                            </Grid.RowDefinitions>
                            
                            <toolkit:ContextMenuService.ContextMenu>
                                <toolkit:ContextMenu>
                                    <toolkit:MenuItem Tag="{Binding Alias}" Click="mnuPin_Click" Header="pin to start" x:Name="mnuPin"></toolkit:MenuItem>
                                    <toolkit:MenuItem Tag="{Binding Alias}" Click="mnuDelete_Click" Header="delete" x:Name="mnuDelete"></toolkit:MenuItem>
                                </toolkit:ContextMenu>
                            </toolkit:ContextMenuService.ContextMenu>
                            
                            <StackPanel>
                                <TextBlock Foreground="Black" Grid.Row="0" FontFamily="Segoe WP Black" FontSize="25" Text="{Binding Alias,Converter={StaticResource BoldNameConverter}}"></TextBlock>
                                <TextBlock Foreground="Black" Grid.Row="0" Text="{Binding Name}"></TextBlock>
                            </StackPanel>

                            <Grid Grid.Row="1">
                                <Grid.Background>
                                    <ImageBrush ImageSource="Images/niner_back.png"></ImageBrush>
                                </Grid.Background>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{Binding Avatar}" Height="78" Width="78" HorizontalAlignment="Left" Margin="10,0,0,0"></Image>
                                    <TextBlock Margin="20,0,0,0" FontSize="40" Text="{Binding Points}" Grid.Column="1" TextAlignment="Right" Foreground="White" VerticalAlignment="Center"></TextBlock>
                                </StackPanel>
                            </Grid>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Grid>
 
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="btnAddUser" Click="btnAddUser_Click" IconUri="/Images/appbar.add.png" Text="add"/>
            <shell:ApplicationBarIconButton x:Name="btnCompare" Click="btnCompare_Click"  IconUri="/Images/appbar.arrow.down.up.png" Text="compare"/>
            <shell:ApplicationBar.MenuItems>
                <!--<shell:ApplicationBarMenuItem Text="settings"/>-->
                <shell:ApplicationBarMenuItem x:Name="btnAbout" Click="btnAbout_Click"  Text="about"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>